package com.cn.aam.checaiduo.ui.me.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.cn.aam.checaiduo.R;
import com.cn.aam.checaiduo.base.adapter.BaseRecycerAdapter;
import com.cn.aam.checaiduo.base.adapter.holder.BaseRecyclerViewHolder;
import com.cn.aam.checaiduo.bean.me.NoticeB;

import butterknife.BindView;

/**
 * monker on 2017/6/15.
 */

public class NoticeAdapter extends BaseRecycerAdapter<NoticeB> {


    public NoticeAdapter(Context mContext) {
        super(mContext);
    }

    @Override
    protected BaseRecyclerViewHolder getViewHolder(View picNewsView) {
        return new NoticeHolder(picNewsView);
    }

    @Override
    protected int getItemLayoutRes() {
        return R.layout.list_notice_item;
    }

    @Override
    protected void ItemVIewChange(BaseRecyclerViewHolder recyclerholder, int position) {
        NoticeHolder holder = (NoticeHolder) recyclerholder;
        String title = getItem(position).getTitle().trim();
//        title = parseTitle(title);
        getItem(position).setTitle(title);
        holder.noticeTvTitle.setText(title);

        holder.noticeTvDate.setText(getItem(position).getCreate_time());
        holder.noticeTvContent.setText(getItem(position).getContent());
    }

    private String parseTitle(String title) {
        if (title.contains("】")) {
            title = title.split("】")[1];
        }
        return title;
    }

    class NoticeHolder extends BaseRecyclerViewHolder {
        @BindView(R.id.notice_tv_title)
        TextView noticeTvTitle;
        @BindView(R.id.notice_tv_date)
        TextView noticeTvDate;
        @BindView(R.id.notice_tv_content)
        TextView noticeTvContent;

        public NoticeHolder(View itemView) {
            super(itemView);
        }
    }
}
